home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 83 / MacAddict_083_2003-07.iso / mac / Software / Development / VLC Source 0.5.3.dmg / src / extras / dirent.h < prev    next >
C/C++ Source or Header  |  2002-11-10  |  4KB  |  149 lines

  1. /*
  2.  * DIRENT.H (formerly DIRLIB.H)
  3.  *
  4.  * by M. J. Weinstein   Released to public domain 1-Jan-89
  5.  *
  6.  * Because I have heard that this feature (opendir, readdir, closedir)
  7.  * it so useful for programmers coming from UNIX or attempting to port
  8.  * UNIX code, and because it is reasonably light weight, I have included
  9.  * it in the Mingw32 package. I have also added an implementation of
  10.  * rewinddir, seekdir and telldir.
  11.  *   - Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  12.  *
  13.  *  This code is distributed in the hope that is will be useful but
  14.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  15.  *  DISCLAIMED. This includeds but is not limited to warranties of
  16.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17.  *
  18.  * $Revision: 1.2 $
  19.  * $Author: sam $
  20.  * $Date: 2002/11/10 18:04:23 $
  21.  *
  22.  */
  23.  
  24. #ifndef    __STRICT_ANSI__
  25.  
  26. #ifndef _DIRENT_H_
  27. #define _DIRENT_H_
  28.  
  29. #ifndef UNDER_CE
  30. #include <io.h>
  31. #endif
  32.  
  33. #ifndef RC_INVOKED
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. struct dirent
  40. {
  41.     long        d_ino;        /* Always zero. */
  42.     unsigned short    d_reclen;    /* Always zero. */
  43.     unsigned short    d_namlen;    /* Length of name in d_name. */
  44.     char*        d_name;        /* File name. */
  45.     /* NOTE: The name in the dirent structure points to the name in the
  46.      *       finddata_t structure in the DIR. */
  47. };
  48.  
  49. /*
  50.  * This is an internal data structure. Good programmers will not use it
  51.  * except as an argument to one of the functions below.
  52.  */
  53. typedef struct
  54. {
  55.     /* disk transfer area for this dir */
  56.     WIN32_FIND_DATA        dd_dta;
  57.  
  58.     /* dirent struct to return from dir (NOTE: this makes this thread
  59.      * safe as long as only one thread uses a particular DIR struct at
  60.      * a time) */
  61.     struct dirent        dd_dir;
  62.  
  63.     /* _findnext handle */
  64.     long            dd_handle;
  65.  
  66.     /*
  67.          * Status of search:
  68.      *   0 = not started yet (next entry to read is first entry)
  69.      *  -1 = off the end
  70.      *   positive = 0 based index of next entry
  71.      */
  72.     short            dd_stat;
  73.  
  74.     /* given path for dir with search pattern (struct is extended) */
  75.     char            dd_name[1];
  76. } DIR;
  77.  
  78.  
  79.  
  80. DIR*        opendir (const char*);
  81. struct dirent*    readdir (DIR*);
  82. int        closedir (DIR*);
  83. void        rewinddir (DIR*);
  84. long        telldir (DIR*);
  85. void        seekdir (DIR*, long);
  86.  
  87.  
  88. /* wide char versions */
  89.  
  90. struct _wdirent
  91. {
  92.     long        d_ino;        /* Always zero. */
  93.     unsigned short    d_reclen;    /* Always zero. */
  94.     unsigned short    d_namlen;    /* Length of name in d_name. */
  95.     wchar_t*    d_name;        /* File name. */
  96.     /* NOTE: The name in the dirent structure points to the name in the
  97.      *       wfinddata_t structure in the _WDIR. */
  98. };
  99.  
  100. /*
  101.  * This is an internal data structure. Good programmers will not use it
  102.  * except as an argument to one of the functions below.
  103.  */
  104. typedef struct
  105. {
  106.     /* disk transfer area for this dir */
  107.     WIN32_FIND_DATA        dd_dta;
  108.  
  109.     /* dirent struct to return from dir (NOTE: this makes this thread
  110.      * safe as long as only one thread uses a particular DIR struct at
  111.      * a time) */
  112.     struct _wdirent        dd_dir;
  113.  
  114.     /* _findnext handle */
  115.     long            dd_handle;
  116.  
  117.     /*
  118.          * Status of search:
  119.      *   0 = not started yet (next entry to read is first entry)
  120.      *  -1 = off the end
  121.      *   positive = 0 based index of next entry
  122.      */
  123.     short            dd_stat;
  124.  
  125.     /* given path for dir with search pattern (struct is extended) */
  126.     wchar_t            dd_name[1];
  127. } _WDIR;
  128.  
  129.  
  130.  
  131. _WDIR*        _wopendir (const wchar_t*);
  132. struct _wdirent* _wreaddir (_WDIR*);
  133. int        _wclosedir (_WDIR*);
  134. void        _wrewinddir (_WDIR*);
  135. long        _wtelldir (_WDIR*);
  136. void        _wseekdir (_WDIR*, long);
  137.  
  138.  
  139. #ifdef    __cplusplus
  140. }
  141. #endif
  142.  
  143. #endif    /* Not RC_INVOKED */
  144.  
  145. #endif    /* Not _DIRENT_H_ */
  146.  
  147. #endif    /* Not __STRICT_ANSI__ */
  148.  
  149.